import {defineStore} from "pinia";

export const useTagsStore = defineStore('tags',{
    state: () => {
        return {
            list: []
        }
    },
    getters: {
        // 判断当前存储的是否有标签
        show: state => {
            return state.list.length > 0
        },
        // 返回所有标签名称
        nameList: state => {
            return state.list.map(item => item.name)
        }
    },
    actions: {
        // 删除标签
        delTagsItem(index) {
            this.list.splice(index, 1)
        },
        // 设置标签
        setTagsItem(data) {
            this.list.push(data)
        },
        // 清除所有标签
        clearTags() {
            this.list = []
        },
        closeTagsOther(data) {
            this.list = data
        }
    }
})

